<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title><%=title %></title>
</head>
<link rel="stylesheet" href="/stylesheets/font-awesome.min.css">
<link rel="stylesheet" href="/stylesheets/bootstrap.css">
<link rel="stylesheet" href="/stylesheets/reset.css">
<link rel="stylesheet" href="/stylesheets/main.css">
<link rel="stylesheet" href="/stylesheets/detail.css">
<body>
	<%- include header -%>
<div class="common-content">
	<input type="hidden" id="USER" value=<%=USER %>>
	<div class="container">
		<div class="main-content detail-area">
		<div class=" post-content">
			<div class="title-area">
				<h1 class="post-title"><%=post.title %></h1>
				<div class="post-detail">
				<ul>
					<li>发布于 <%=post.time %></li>
					<li>作者 <%=post.user.username %></li>
					<li>32 次浏览</li>
					<li>来自 <%=post.type.description %></li>
				</ul>
				</div>

				<button class="btn btn-default btn-success">收藏</button>
			</div>

			<div class="post-container">
				<% post.content.forEach(function(p,key){ %>
					<p><%=p %></p>
				<% })%>
			</div>

		</div>

		<% if(comments.length >0) { %>         
		<div class=" comment-area">
			
			<h2 class="common-title comment-title" ><span><%=commentCount %></span> 回复</h2>
			<%  comments.forEach(function(comment,key){ %>
			<div class="comment-main clearfix">
				<div class="img-area">
					<a class="person-img" href=""><img src=<%=comment.user.head %> alt=""></a>
				</div>
				<div class="comment-container">
					<div class="comment-detail clearfix"><span class="comment-user-name"><%=comment.user.username%></span><span class="comment-building-number"><%=comment.buildingNum %>楼</span><span class="comment-time"><%=comment.time %></span>
					<div class="function-area">
						<span class="thumbs"><i class="fa fa-thumbs-o-up" ></i><span class="thumbs-up-count"><%=comment.thumbsUpCount%></span></span><input type="hidden" class="comment-id" value=<%=comment._id %>><span class="reply"><i class="fa fa-reply"></i></span>
					</div>
					
					</div>
					<div class="comment-content">
						<p><%=comment.content %></p>
					</div>
					
				</div>

			</div>
				<%}) %>
			</div>

			<% }%>

		

		<div class=" reply-form">
			
			<h2 class="common-title reply-title">添加回复</h2>
			<div class="reply-content">
				<form action="/saveComment" class="form-horizontal" id="comment_form" method="post">
					<textarea name="comment[content]" id="comment_content" class="col-sm-12 text-input" rows="10"></textarea>
					<% if(USER){%>  
					<input type="hidden" name ="comment[user]" value=<%=USER._id %> >
					<% } %>
					<input type="hidden" name ="comment[post]" value =<%=post._id %> >
					<input type="hidden" name = "comment[buildingNum]" id="comment_buildingNum" value=<%=commentCount %>>
					<div class="btn-area">
						
						<button class="btn btn-default btn-primary" id="comment_btn" type="button">回复</button> 

						<span class="err" id="comment_err"></span>


					</div>
					
				

				</form>
			</div>
		</div>

		</div>

		

		

		<div class="slide-content">
			<div class="user-info">
				<h2 class="slide-title">作者</h2>
				<div class="user-main-info">
					<a href="" class="user-img"><img src=<%=post.user.head %> alt=""></a>
					<span class="user-name"><%=post.user.username %></span>
				</div>
				<p class="user-sign">"这个同学很懒，什么都没有留下。"</p>
			</div>
			<% if(anotherPosts.length>0) {%>
			<div class="user-topic">
				<h2 class="slide-title">作者其他话题</h2>
				<ul class="user-topic-list">
					<% anotherPosts.forEach(function(anotherPost,key){ %>
						<li class="item"><a href='/topic/<%=anotherPost._id %>'><%=anotherPost.title %></a></li>
					<% }) %>
				</ul>
			</div>
			<% } %>
			<% if(noCommentPost.length > 0 ){ %> 
			<div class="no-command-note">
					<h2 class="slide-title">无人回复的话题</h2>
					<ul class="no-command-note-list">
					<% noCommentPost.forEach(function(item,key){ %>
						<li class="no-command-note-list-item"><a href="/topic/<%=item._id %>"><%=item.title %></a></li>
					<% }) %>
					</ul>
				</div>

			<%  }  %>

		</div>






	</div>



</div>

<%- include footer -%>
<script src="/js/jquery-1.11.1.js"></script>
<script src="/js/detail.js"></script>
</body>
</html>